﻿using UnityEngine;
using System.Collections;
using UI;
using UnityEngine.UI;
using Base.Extensions;
using System.Collections.Generic;
using System;

public class 保养清单 : BasePanel
{
    public UnityEngine.Object Object;
    private Transform form;
    private void Awake()
    {
        form = transform.Find("Scroll View/Viewport/Content");
    }
    public override void OnEnter()
    {
        gameObject.SetActive(true);
    }
    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }
    public override void OnExit()
    {
        gameObject.SetActive(false);
    }
    private  string GetGuid()
    {
        Guid guid = new Guid();
        guid = Guid.NewGuid();
        return guid.ToString();
    }
public void 新建表单(Transform form)
    {
        form.Find("Titles/InputField").SetInputText(GetGuid().Replace('-',' '));
        form.Find("Titles/InputField1").SetInputText(System.DateTime.Now.ToString());
        form.Find("Titles/InputField2").SetInputText("输入保养内容");
        //form.Find("Titles/Dropdown/Label").SetText("保养人");
        form.Find("Titles/Text").SetText("派单");
        form.Find("Titles/Text1").SetText("未维修");
        form.Find("Titles/Text2").SetText("未审核");
    }

    public void 提交新建表单(Transform transform)
    {
        Debug.LogError("注册新建表单事件完成添加记录");
        注册维护表单(transform);
    }

    void 注册维护表单(Transform _transform)
    {
        GameObject _gameObject = Instantiate(Object) as GameObject;
        _gameObject.SetActive(true);
        _gameObject.transform.parent = form;
        _gameObject.transform.localPosition = Vector3.zero;
        _gameObject.transform.localScale = Vector3.one;

        string code = _transform.Find("Titles/InputField/Text").GetText();
        string time = _transform.Find("Titles/InputField1/Text").GetText();
        string cont = _transform.Find("Titles/InputField2/Text").GetText();
        string root = _transform.Find("Titles/Dropdown/Label").GetText();
        string stare = _transform.Find("Titles/Text").GetText();
        string over = _transform.Find("Titles/Text1").GetText();
        string psir = _transform.Find("Titles/Text2").GetText();




        _gameObject.transform.Find("Titles/Text").SetText(code);
        _gameObject.transform.Find("Titles/Text (1)").SetText(time);
        _gameObject.transform.Find("Titles/Text (2)").SetText(cont);
        _gameObject.transform.Find("Titles/Text (3)").SetText(root);
        _gameObject.transform.Find("Titles/Text (4)").SetText("日常保养");
        _gameObject.transform.Find("Titles/Text (5)").SetText(System.DateTime.Now.ToString());
        _gameObject.transform.Find("Titles/Text (6)").SetText("张三");
        _gameObject.transform.Find("Titles/Text (7)").SetText(stare);
    }

    public void 关闭界面()
    {
        UIManager.Instance.PopPanel();
    }
}
